package com.itheima.tlias.tliasweb.util;

public class UrlUtil {

    public static String join(String part1, String part2){
        if(part1 == null){
            return part2;
        }
        if(part2 == null){
            return part1;
        }
        if(part1.endsWith("/")){
            part1 = part1.substring(0, part1.length()-1);
        }
        if(part2.startsWith("/")){
            part2 = part2.substring(1);
        }
        return part1+"/"+part2;
    }

    public static void main(String[] args) {
        String join = join("http://www.baidu.com/", "/api/user/1");
        System.out.println(join);
    }

}
